﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Sample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            this.qguctoc1.BuddyControl = this.qgucMapControl1;

            this.qgucMapControl1.AddLayer(@"e:\共享\scdistrict.shp");

            AxMapWinGIS.AxMap mapCtrl = this.qgucMapControl1.AxMap;
			if (mapCtrl == null)				return;
            int hwnd= mapCtrl.get_LayerHandle(0);

           this.Text= mapCtrl.get_LayerName(hwnd);


           this.menuFileQuit.Click += new EventHandler(MenuFileQuit_Click);

           this.menuEditRemoveLayer.Click += delegate { this.qgucMapControl1.RemoveLayer(0); };
        }

        private void toolAdd_Click(object sender, EventArgs e)
        {
            oqis.core.common.file.FileOperator fo = new oqis.core.common.file.FileOperator();
           string file= fo.GetSelectedFile("*.shp");

           this.qgucMapControl1.AddLayer(file);
 
        }

        private void toolLayers_Click(object sender, EventArgs e)
        {
            int layersCount=this.qgucMapControl1.AxMap.NumLayers;
            MessageBox.Show(layersCount.ToString());
            int handler=0;
            for (int i = 0; i < layersCount; ++i)
            {
                handler = this.qgucMapControl1.AxMap.get_LayerHandle(i);
               MessageBox.Show( this.qgucMapControl1.AxMap.get_LayerFilename(handler));

            }
 

        }
        
        void MenuFileQuit_Click(object sender, EventArgs e)
        {
        	Environment.Exit(0);
        }

        private void menuEditClearLayer_Click(object sender, EventArgs e)
        {
            this.qgucMapControl1.ClearLayers();
        }
    }
}
